var mongoose = require('../../models/model');
var TagModel = require('../../models/tag');

exports.index = function(req,res){
	TagModel.find({},function(err,data){
		if(err){
			console.log(err);
		}

		res.render('admin/tag_list',{title:'Tomorrow Blog',tags:data});
	});
};

exports.add = function(req,res){
	res.render('admin/tag_add',{title:'Tomorrow Blog'});
};

exports.doAdd = function(req,res){
	var data = {
		name : req.body.name,
		order_sort : req.body.order_sort,
		is_show : req.body.is_show,
		is_nav : req.body.is_nav,
		intro : req.body.intro
	};

	var TagEntity = new TagModel(data);
	TagEntity.save(function(err){
		if(err){
			console.log(err)
		}
		res.redirect('/admin/tag');
	});
};